/**
 * Copyright 2008 Benjamin Possolo
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.javenue.util.process;

/**
 * A <tt>ProcessTerminationListener</tt> can be registered with a <tt>Process</tt> so that it is
 * notified when the <tt>Process</tt> finishes executing its <code>run()</code> method.
 * <p>
 * It may be necessary to handle cases where a <tt>Process</tt> terminates unexpectedly.
 * Usually, a concrete process will notify all <tt>ProcessTerminationListener</tt>s that have
 * registered with it before it's run method completes. When notified, a 
 * <tt>ProcessTerminationListener</tt>'s <code>processTerminated()</code> 
 * method is invoked and a reference to the process which terminated is passed as a parameter.
 * 
 * @see Process
 * @author Benjamin Possolo
 * <p>Created on May 23, 2007
 */
public interface ProcessTerminationListener {
	
	/**
	 * The callback method that is invoked when a process terminates.
	 * <p>
	 * This method is invoked by the thread that is executing the <tt>Process</tt>'s
	 * <code>run()</code> method.
	 * 
	 * @param process a reference to the <tt>Process</tt> that completed execution.
	 */
	void processTerminated(Process<? extends ProcessState> process);
}
